<script setup lang="ts">
import { ref,onMounted} from 'vue'
import Edit from './components/Edit.vue'
import Report from './components/Report.vue'

import { useCache } from "@/hooks/web/useCache";
import { useAppStore } from "@/store/modules/app";
import { Base64 } from 'js-base64'
import api from '@/api';
import { useRouter } from 'vue-router'

defineOptions({
    name: 'sensoryReport'
})
const { getSensoryByIdDevice} = api;
const reportState=ref("正在加载报告...");
const reportId=ref<string|string[]>("0");
const reportData=ref(null);
const router = useRouter()
const getReportData=async ()=>{
    reportId.value = router.currentRoute.value.query.id;
    if(!reportId.value)throw new Error("没有报告id");
     const reportRes = await getSensoryByIdDevice({ id:reportId.value });
     return reportRes.data;
}
const pageLoad=async ()=>{
    reportData.value=await getReportData();         
    reportState.value="ok"
}
onMounted(() => {
    pageLoad()
})

</script>
<template>  
    <Report v-if="reportState==='ok'" :current-row="reportData" />
    <div v-else>正在加载报告</div>
</template>